/*
 * @Author: dvlproad
 * @Date: 2023-10-30 18:28:40
 * @LastEditors: dvlproad
 * @LastEditTime: 2023-10-31 17:50:03
 * @Description: 
 */
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

import 'ts_shared_normalview_notifier.dart';

class TSSharedNormalViewContainer extends StatelessWidget {
  const TSSharedNormalViewContainer({super.key});

  @override
  Widget build(BuildContext context) {
    // return MultiProvider(
    //   providers: [
    //     ChangeNotifierProvider(
    //         create: (_) => TSSharedNormalViewContainerModel()),
    //   ],
    //   child: _buildContent(context),
    // );
    return _buildContent(context);
  }

  Widget _buildContent(BuildContext context) {
    /// Calls `context.read` instead of `context.watch` so that it does not rebuild when [Counter] changes.
    // var model_read = context.read<TSSharedNormalViewContainerModel>();

    /// Calls `context.watch` to make [Count] rebuild when [Counter] changes.
    var model_watch = context.watch<TSSharedNormalViewContainerModel>();

    return Container(
      color: Colors.green,
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          const Text(
            '我是一个视图实例',
            style: TextStyle(fontSize: 16),
          ),
          ElevatedButton(
            onPressed: model_watch.addCount,
            style: ElevatedButton.styleFrom(
              backgroundColor: Colors.grey,
              foregroundColor: Colors.red,
            ),
            child: const Text('点击我'),
          ),
          Text(
            '${model_watch.count}',
            style: const TextStyle(fontSize: 16),
          ),
        ],
      ),
    );
  }
}
